<template>
  <div class="feedback-container">
   <el-card class="card-form">
      <div slot="header">
        <span>意见反馈</span>
      </div>
   <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="save-ruleForm">
      <el-form-item label="反馈类型" prop="qaType">
        <el-radio-group v-model="ruleForm.qaType">
            <el-radio :label="0">课程</el-radio>
            <el-radio :label="1">技术</el-radio>
            <el-radio :label="2">其他</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="反馈内容" prop="feedbackContent">
         <el-input
          type="textarea"
          :rows="10"
          placeholder="请输入反馈内容"
          v-model="ruleForm.feedbackContent"> 
         </el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-finished" :loading="submitType" size="medium" @click="submitForm('ruleForm')">提交</el-button>
        <el-button icon="el-icon-setting"  size="medium" @click="resetForm('ruleForm')">重置</el-button>
      </el-form-item>
    </el-form>
</el-card>

 
  </div>
</template>
<script>
import {saveFeedback} from '@/api/clientManage'
export default {
  data() {
    return {
         ruleForm: {
          qaType: 0,
          feedbackContent: ''
        },
        submitType:false,
        rules: {
          feedbackContent: [
            { required: true, message: '请输入反馈内容', trigger: 'change' }
          ]
        }
    }
  },
  computed: {},
  created() {
  },
  methods: {
       submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.submitType =true
            saveFeedback(this.ruleForm).then((res) => {
            if (res.code === 0) {
              this.$message.success("感谢您的建议，提交成功!");
              this.resetForm('ruleForm')
            } else {
              this.$message.error(res.message||"操作失败");
            }
            setTimeout(() => {
              this.submitType =false
            }, 500);
          })
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
  }
}
</script>
<style lang="scss">
.feedback-container {
  padding: 16px;
  box-sizing: border-box;
  height: calc(100vh - 84px);
  .card-form{
     height: calc(100vh - 104px);
  }
  .save-ruleForm{
    width:600px;
  }
}
</style>
